﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _测试手动创建DBContext
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            BindInit();
        }

        public void BindInit()
        {
            btnSearch.Click += new EventHandler(btnSearch_Clikc);
        }

        public void btnSearch_Clikc(object sender, EventArgs e)
        {
            string txtStuNum = txtSearch.Text.Trim();
            using (var db = new BaseContext())
            {
                //var list = db.Database.SqlQuery<Sp_StudentScore_RowToColumn_Result>("exec Sp_StudentScore_RowToColumn @StuNum", new SqlParameter("@StuNum", txtStuNum)).ToList();
                //dataGridView1.DataSource = list;
                //List<Sp_StudentScore_RowToColumn_Result> list = db.Sp_StudentScore_RowToColumn(txtStuNum).ToList();
                //dataGridView1.DataSource = list;
               var list = db.Database.SqlQuery<List<Dictionary<string, object>>>("exec Sp_StudentScore_RowToColumn @StuNum", new SqlParameter("@StuNum", txtStuNum)).ToList();
            }
        }
    }
}
